const fs = require('fs')
const path = require('path')
const { settingsIcon, refreshIcon } = require('./icons')

// 将 Base64 转换为图片文件
function base64ToImage(base64Str, filePath) {
  const base64Data = base64Str.replace(/^data:image\/png;base64,/, '')
  fs.writeFileSync(filePath, Buffer.from(base64Data, 'base64'))
}

// 生成图标
function generateIcons() {
  const assetsDir = path.join(__dirname)
  
  // 确保目录存在
  if (!fs.existsSync(assetsDir)) {
    fs.mkdirSync(assetsDir, { recursive: true })
  }

  // 生成图标文件
  base64ToImage(settingsIcon, path.join(assetsDir, 'settings.png'))
  base64ToImage(refreshIcon, path.join(assetsDir, 'refresh.png'))
}

generateIcons() 